package com.szml.permission.controller;

import com.szml.permission.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author limin
 * @date 2025-06-20 20:27
 * @description
 */
@RestController
@RequestMapping("/permission")
public class PermissionController {
    @Autowired
    private PermissionService permissionService;

    @PostMapping("/bindDefaultRole")
    public void bindDefaultRole(@RequestParam Long userId) {
        permissionService.bindDefaultRole(userId);
    }

    @GetMapping("/getUserRoleCode")
    public String getUserRoleCode(@RequestParam Long userId) {
        String roleCode = permissionService.getUserRoleCode(userId);
        return roleCode;
    }

    @PostMapping("/upgradeToAdmin")
    public void upgradeToAdmin(@RequestParam Long userId) {
        permissionService.upgradeToAdmin(userId);
    }

    @PostMapping("/downgradeToUser")
    public void downgradeToUser(@RequestParam Long userId) {
        permissionService.downgradeToUser(userId);
    }


}
